package com.zkzx.wlhy.adaptor.controller.truck;

import com.zkzx.common.constants.SourceEnum;
import com.zkzx.common.truck.command.TruckCommand;
import com.zkzx.common.truck.constants.TruckStatusEnum;
import com.zkzx.common.truck.model.TruckVO;
import com.zkzx.wlhy.adaptor.service.code.WlhyCode;
import com.zkzx.wlhy.adaptor.service.truck.TruckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 北京中科智兴物联科技有限公司 @版权所有
 *
 * @Author: zhaoyihe@zkraising.com
 * @Date: 2021/05/21/0:11
 * @Description:
 */
@RestController
@Validated
@Api( tags="车辆接口")
@RequestMapping(value = "/trucks")
public class TruckController {

    @Autowired
    private TruckService truckService;

    @GetMapping("/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "查询是否存在该车辆", notes = "查询是否存在该车辆")
    public TruckCommand getTruck(@PathVariable("id") Integer id, @RequestParam("header_license") String headerLicense){

//        TruckCommand truckCommand = new TruckCommand();
//        truckCommand.setId(id);
//        truckCommand.setStatus(TruckStatusEnum.APPROVE_ING.name());
//        return truckCommand;
        return truckService.getTruck(id,headerLicense);
    }

    @PostMapping("/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "添加车辆信息", notes = "添加车辆信息")
    public TruckCommand add(@PathVariable("id") Integer id, @RequestParam("company_three_id") String companyThreeId,@RequestBody @Valid TruckVO truckVO){
        return truckService.add(id,companyThreeId,truckVO);
    }

    @GetMapping("/{id}/status")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "查询车辆审核状态", notes = "查询车辆审核状态")
    public TruckCommand getStatus(@PathVariable("id") Integer id, @RequestParam("three_id") String threeId){

        return truckService.getStatus(id,threeId);
    }



}
